pull code: clean up mirrorlist hack
authorJonathan Lebon <jlebon@redhat.com>
Wed, 31 Aug 2016 17:16:36 +0000 (13:16 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 31 Aug 2016 18:54:59 +0000 (18:54 +0000)
While converting the mirrorlist code from using GSList to GPtrArray, I
completely missed the fact that there is now a much cleaner way to do
this.

Closes: #484
Approved by: cgwalters

src/libostree/ostree-repo-pull.c

index 2448d51e1676739098d64846a3c5dfeb838e2b01..76c29272f4d3eede0a94ab701cc4a9415ac89dc4 100644 (file)
@@ -2471,9 +2471,10 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
       goto out;
 
     if (contenturl == NULL)
-      /* this is a bit hacky but greatly simplifies coding elsewhere; we take
-       * care in the out path to not double free if they're the same list */
-      pull_data->content_mirrorlist = pull_data->meta_mirrorlist;
+      {
+        pull_data->content_mirrorlist =
+          g_ptr_array_ref (pull_data->meta_mirrorlist);
+      }
     else
       {
         if (g_str_has_prefix (contenturl, "mirrorlist="))
@@ -3026,10 +3027,8 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
   g_clear_object (&pull_data->cancellable);
   g_clear_object (&pull_data->remote_repo_local);
   g_free (pull_data->remote_name);
-  if (pull_data->content_mirrorlist != pull_data->meta_mirrorlist)
-    g_clear_pointer (&pull_data->content_mirrorlist, (GDestroyNotify) g_ptr_array_unref);
-  /* we clear this *after* clearing content_mirrorlist to avoid unref'ing twice */
   g_clear_pointer (&pull_data->meta_mirrorlist, (GDestroyNotify) g_ptr_array_unref);
+  g_clear_pointer (&pull_data->content_mirrorlist, (GDestroyNotify) g_ptr_array_unref);
   g_clear_pointer (&pull_data->summary_data, (GDestroyNotify) g_bytes_unref);
   g_clear_pointer (&pull_data->summary_data_sig, (GDestroyNotify) g_bytes_unref);
   g_clear_pointer (&pull_data->summary, (GDestroyNotify) g_variant_unref);